<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //使用async_await 封装 ajax
        //接口地址：https://api.apiopen.top/api/sentences
        function sendAjaxGet(url) {
            return new Promise((resolve, reject)=>{
                    let xhr = new XMLHttpRequest();
                    xhr.open("GET", url)
                    xhr.send()
                    xhr.onreadystatechange = function() {
                        if(xhr.readyState === 4){
                            if(xhr.status >= 200 && xhr.status < 300){
                                //请求成功
                                resolve(xhr.response)
                            }else{
                                //请求失败
                                reject(xhr.status)
                            }
                        }
                    }
                }
            )
        }

        let url = "https://api.apiopen.top/api/sentences"
        async function main() {
            let res1 = await sendAjaxGet(url)
            let res2 = await sendAjaxGet(url)
            let res3 = await sendAjaxGet(url)
            console.log(JSON.parse(res1).result)
            console.log(JSON.parse(res2).result)
            console.log(JSON.parse(res3).result)
        }
        
        main()
    </script>
</body>
</html>